<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首页</title>
    <!--semantic-ui-->
    <link href="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">
</head>
<body>

<!--主容器-->
<div class="ui container">

    <div class="ui segment" id="index-header-nav" th:fragment="nav-menu">
        <div class="ui secondary menu">
            <a class="item" th:href="@{/admin/index}">首页</a>

            <!--登录注销-->
            <div class="right menu">
                <!--如果没有登录-->
                <div sec:authorize="!isAuthenticated()">
                    <a class="item" th:href="@{/admin/toLogin}">
                        <i class="address card icon"></i> 登录
                    </a>
                </div>

                <!--如果登录：用户名，注销-->
                <div sec:authorize="isAuthenticated()">
                    <a class="item">
                        用户名：<span sec:authentication="name"></span>
                        角色：<span sec:authentication="authorities"></span>
                    </a>
                </div>
                <div sec:authorize="isAuthenticated()">
                    <a class="item" th:href="@{/logout}">
                        <i class="sign-out icon"></i> 注销
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="ui segment" style="text-align: center">
    <h3>Spring Security Study by 秦疆</h3>
</div>

<div>
    <br>
    <div class="ui three column stackable grid">
        <!--动态菜单的效果-->
        <div class="column" sec:authorize="hasAnyAuthority('guest')">
            <div class="ui raised segment">
                <div class="ui">
                    <div class="content">
                        <h5 class="content">guest</h5>
                        <hr>
                        <div>
                            <a th:href="@{'/admin/toAdminPage/'+${#authentication.getName()}}">
                                <i class="bullhorn icon"></i> 查询自己的信息
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="column" sec:authorize="hasAnyAuthority('admin')">
            <div class="ui raised segment">
                <div class="ui">
                    <div class="content">
                        <h5 class="content">admin</h5>
                        <hr>
                        <div><a th:href="@{/admin/toAdminAllPage}"><i class="bullhorn icon"></i> 查询所有管理员 </a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>